#include "gtkrecentchooserprivate.h"
#include "gtkrecentmanager.h"
#include "deprecated/gtkrecentaction.h"
-#include "deprecated/gtkactivatable.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
LAST_SIGNAL
};
-static gboolean recent_chooser_has_show_numbers (GtkRecentChooser *chooser);
-
-static GQuark quark_gtk_related_action = 0;
-static GQuark quark_gtk_use_action_appearance = 0;
-static const gchar gtk_related_action_key[] = "gtk-related-action";
-static const gchar gtk_use_action_appearance_key[] = "gtk-use-action-appearance";
-
-
static guint chooser_signals[LAST_SIGNAL] = { 0, };
{
GType iface_type = G_TYPE_FROM_INTERFACE (iface);
- quark_gtk_related_action = g_quark_from_static_string (gtk_related_action_key);
- quark_gtk_use_action_appearance = g_quark_from_static_string (gtk_use_action_appearance_key);
-
/**
* GtkRecentChooser::selection-changed:
* @chooser: the object which received the signal
return show_tips;
}
-static gboolean
-recent_chooser_has_show_numbers (GtkRecentChooser *chooser)
-{
- GParamSpec *pspec;
-
- /* This is the result of a minor screw up: the "show-numbers" property
- * was removed from the GtkRecentChooser interface, but the accessors
- * remained in the interface API; now we need to check whether the
- * implementation of the RecentChooser interface has a "show-numbers"
- * boolean property installed before accessing it, and avoid an
- * assertion failure using a more graceful warning. This should really
- * go away as soon as we can break API and remove these accessors.
- */
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
- "show-numbers");
-
- return (pspec && pspec->value_type == G_TYPE_BOOLEAN);
-}
-
/**
* gtk_recent_chooser_set_sort_type:
* @chooser: a #GtkRecentChooser
g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
}
-
-void
-_gtk_recent_chooser_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
-{
- GtkRecentChooser *recent_chooser;
- GtkRecentChooser *action_chooser;
- GtkRecentAction *recent_action;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- recent_chooser = GTK_RECENT_CHOOSER (activatable);
- action_chooser = GTK_RECENT_CHOOSER (action);
- recent_action = GTK_RECENT_ACTION (action);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (strcmp (property_name, "show-numbers") == 0 && recent_chooser_has_show_numbers (recent_chooser))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- g_object_set (recent_chooser, "show-numbers",
- gtk_recent_action_get_show_numbers (recent_action), NULL);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
- else if (strcmp (property_name, "show-private") == 0)
- gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
- else if (strcmp (property_name, "show-not-found") == 0)
- gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
- else if (strcmp (property_name, "show-tips") == 0)
- gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
- else if (strcmp (property_name, "show-icons") == 0)
- gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
- else if (strcmp (property_name, "limit") == 0)
- gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
- else if (strcmp (property_name, "local-only") == 0)
- gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
- else if (strcmp (property_name, "sort-type") == 0)
- gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
- else if (strcmp (property_name, "filter") == 0)
- gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
-}
-
-void
-_gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action)
-{
- GtkRecentChooser *recent_chooser;
- GtkRecentChooser *action_chooser;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- recent_chooser = GTK_RECENT_CHOOSER (activatable);
- action_chooser = GTK_RECENT_CHOOSER (action);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (!action)
- return;
-
- if (recent_chooser_has_show_numbers (recent_chooser))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- g_object_set (recent_chooser, "show-numbers",
- gtk_recent_action_get_show_numbers (GTK_RECENT_ACTION (action)),
- NULL);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
- gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
- gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
- gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
- gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
- gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
- gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
- gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
- gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
-}
-
-void
-_gtk_recent_chooser_set_related_action (GtkRecentChooser *recent_chooser,
- GtkAction *action)
-{
- GtkAction *prev_action;
-
- prev_action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
-
- if (prev_action == action)
- return;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (recent_chooser), action);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action, action);
-}
-
-GtkAction *
-_gtk_recent_chooser_get_related_action (GtkRecentChooser *recent_chooser)
-{
- return g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
-}
-
-/* The default for use-action-appearance is TRUE, so we try to set the
- * qdata backwards for this case.
- */
-void
-_gtk_recent_chooser_set_use_action_appearance (GtkRecentChooser *recent_chooser,
- gboolean use_appearance)
-{
- GtkAction *action;
- gboolean use_action_appearance;
-
- action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
- use_action_appearance = !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
-
- if (use_action_appearance != use_appearance)
- {
-
- g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance, GINT_TO_POINTER (!use_appearance));
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (recent_chooser), action);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-}
-
-gboolean
-_gtk_recent_chooser_get_use_action_appearance (GtkRecentChooser *recent_chooser)
-{
- return !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
-}
#include "gtklabel.h"
#include "gtkbox.h"
#include "gtktooltip.h"
-#include "deprecated/gtkactivatable.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
enum {
PROP_0,
PROP_SHOW_NUMBERS,
-
- /* activatable properties */
- PROP_ACTIVATABLE_RELATED_ACTION,
- PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
};
static void manager_changed_cb (GtkRecentManager *manager,
gpointer user_data);
-static void gtk_recent_chooser_activatable_iface_init (GtkActivatableIface *iface);
-static void gtk_recent_chooser_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name);
-static void gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserMenu,
gtk_recent_chooser_menu,
GTK_TYPE_MENU,
G_ADD_PRIVATE (GtkRecentChooserMenu)
G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
- gtk_recent_chooser_iface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
- gtk_recent_chooser_activatable_iface_init))
-G_GNUC_END_IGNORE_DEPRECATIONS;
+ gtk_recent_chooser_iface_init))
static void
gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface)
iface->list_filters = gtk_recent_chooser_menu_list_filters;
}
-static void
-gtk_recent_chooser_activatable_iface_init (GtkActivatableIface *iface)
-{
- iface->update = gtk_recent_chooser_update;
- iface->sync_action_properties = gtk_recent_chooser_sync_action_properties;
-}
-
static void
gtk_recent_chooser_menu_class_init (GtkRecentChooserMenuClass *klass)
{
P_("Whether the items should be displayed with a number"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-
- g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
- g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
}
static void
case GTK_RECENT_CHOOSER_PROP_FILTER:
gtk_recent_chooser_menu_set_current_filter (menu, g_value_get_object (value));
break;
- case PROP_ACTIVATABLE_RELATED_ACTION:
- _gtk_recent_chooser_set_related_action (GTK_RECENT_CHOOSER (menu), g_value_get_object (value));
- break;
- case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
- _gtk_recent_chooser_set_use_action_appearance (GTK_RECENT_CHOOSER (menu), g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case GTK_RECENT_CHOOSER_PROP_FILTER:
g_value_set_object (value, priv->current_filter);
break;
- case PROP_ACTIVATABLE_RELATED_ACTION:
- g_value_set_object (value, _gtk_recent_chooser_get_related_action (GTK_RECENT_CHOOSER (menu)));
- break;
- case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
- g_value_set_boolean (value, _gtk_recent_chooser_get_use_action_appearance (GTK_RECENT_CHOOSER (menu)));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_object_notify (G_OBJECT (menu), "show-tips");
}
-static void
-gtk_recent_chooser_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
-{
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (strcmp (property_name, "sensitive") == 0)
- gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- _gtk_recent_chooser_update (activatable, action, property_name);
-}
-
-static void
-gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action)
-{
- if (!action)
- return;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- _gtk_recent_chooser_sync_action_properties (activatable, action);
-}
-
-
/*
* Public API
*/